| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415 |
- <template>
- <div>
- <!-- 数据表格 -->
- <ele-pro-table
- ref="table"
- :columns="columns"
- :datasource="datasource"
- :need-page="true"
- :selection.sync="selection"
- :current.sync="rowCurrent"
- @sort-change="onSortChange"
- highlight-current-row
- height="calc(100vh - 500px)"
- full-height="calc(100vh - 116px)"
- tool-class="ele-toolbar-form"
- :page-size="pageSize"
- :initLoad="false"
- @columns-change="handleColumnChange"
- :cache-key="cacheKeyUrl"
- v-if="pageShow"
- >
- <!-- 表头工具栏 -->
- <template v-slot:toolbar>
- <el-button
- size="small"
- type="primary"
- icon="el-icon-plus"
- class="ele-btn-icon"
- @click="openEdit({}, 2)"
- v-if="$hasPermission('main:category:save')"
- >
- 新建
- </el-button>
- <div
- class="upload"
- v-if="rootTreeId == 6 && $hasPermission('main:category:update')"
- >
- <el-upload
- v-if="!isLoading"
- :show-file-list="false"
- class="upload-demo"
- action=""
- :before-upload="beforeUpload"
- :on-success="successUpload"
- :on-error="errorUpload"
- >
- <slot>
- <el-button
- type="primary"
- size="small"
- plain
- icon="el-icon-upload2"
- >导入</el-button
- >
- </slot>
- </el-upload>
- <el-button
- v-else
- type="primary"
- size="small"
- icon="el-icon-upload2"
- plain
- :loading="isLoading"
- >导入</el-button
- >
- </div>
- <el-button
- v-if="$hasPermission('main:category:update') && rootTreeId != 6"
- type="primary"
- size="small"
- icon="el-icon-upload2"
- plain
- @click="uploadFile"
- >导入</el-button
- >
- <el-button
- type="warning"
- icon="el-icon-download"
- size="mini"
- @click="handleExport()"
- :loading="exportLoading"
- >导出</el-button
- >
- <el-button
- v-if="!isBatchPublish"
- size="small"
- type="primary"
- icon="el-icon-s-promotion"
- class="ele-btn-icon"
- @click="batchPublish"
- >
- 批量发布
- </el-button>
- <el-button
- size="small"
- :disabled="selection.length == 0"
- icon="el-icon-thumb"
- class="ele-btn-icon"
- @click="moveTo()"
- v-if="$hasPermission('main:category:update')"
- >
- 设置采购员
- </el-button>
- <el-button
- size="small"
- :disabled="selection.length == 0"
- icon="el-icon-thumb"
- class="ele-btn-icon"
- @click="warehouseOpen"
- v-if="$hasPermission('main:category:update')"
- >
- 设置默认仓库
- </el-button>
- <!-- <el-button
- v-if="rootTreeId == 9"
- size="small"
- type="primary"
- @click="handleLink('4')"
- >关联设备</el-button
- >
- <el-button
- v-if="rootTreeId == 9"
- size="small"
- type="primary"
- @click="handleLink('5')"
- >关联模具</el-button
- >
- <el-button
- v-if="rootTreeId == 9"
- size="small"
- type="primary"
- @click="handleLink('8')"
- >关联舟皿</el-button
- >
- <el-button
- v-if="rootTreeId == 4"
- size="small"
- type="primary"
- @click="handleLink('5')"
- >关联模具</el-button
- >
- <el-button
- v-if="rootTreeId == 4"
- size="small"
- type="primary"
- @click="handleLink('6')"
- >关联备品备件</el-button
- >-->
- </template>
- <template v-slot:isEnabled="{ row }">
- <div>
- <el-switch
- v-model="row.isEnabled"
- active-color="#13ce66"
- inactive-color="#ff4949"
- :active-value="1"
- :inactive-value="0"
- :disabled="isApproving(row)"
- @change="changeEnable(row)"
- >
- </el-switch>
- </div>
- </template>
- <template v-slot:code="{ row }">
- <el-link type="primary" :underline="false" @click="openEdit(row, 3)">
- {{ row.code }}
- </el-link>
- </template>
- <template v-slot:name="{ row }">
- <el-link type="primary" :underline="false" @click="openEdit(row, 3)">
- {{ row.name }}
- </el-link>
- </template>
- <template v-slot:componentAttribute="{ row }">
- <div>
- <!-- {{ }} -->
- {{ getDictValueFn(row.componentAttribute) }}
- </div>
- </template>
- <template v-slot:approveStatus="{ row }">
- <el-tag
- v-if="hasApproveStatus(row)"
- size="mini"
- :type="getApproveStatusTagType(row)"
- >
- {{ getApproveStatusText(row) }}
- </el-tag>
- </template>
- <template v-slot:action="{ row }">
- <!-- <el-link
- type="primary"
- :underline="false"
- @click="openEdit(row, 3)"
- v-if="isApproving(row)"
- >
- 详情
- </el-link> -->
- <!-- <el-link
- type="primary"
- :underline="false"
- @click="openEdit(row, 1)"
- v-if="$hasPermission('main:category:update')"
- >
- {{ row.isEnabled == 1 ? '停用' : '启用' }}
- </el-link> -->
- <el-link
- type="primary"
- :underline="false"
- @click="openEdit(row, 1)"
- v-if="!isApproving(row) && $hasPermission('main:category:save')"
- >
- 复制
- </el-link>
- <!-- <el-link type="primary" :underline="false" @click="openEdit(row, 3)">
- 详情
- </el-link> -->
- <el-link
- type="primary"
- :underline="false"
- @click="openEdit(row, 0)"
- v-if="!isApproving(row) && $hasPermission('main:category:update')"
- >
- 修改
- </el-link>
- <el-popconfirm
- class="ele-action"
- title="确定要删除此物料吗?"
- @confirm="remove(row)"
- v-if="
- !isApproving(row) &&
- !isApprovePassed(row) &&
- $hasPermission('main:category:delete')
- "
- >
- <template v-slot:reference>
- <el-link type="danger" :underline="false"> 删除 </el-link>
- </template>
- </el-popconfirm>
- <!-- <el-link
- type="primary"
- v-if="row.isProduct == 1"
- :underline="false"
- @click="openParam(row)"
- >
- 工艺参数
- </el-link> -->
- <el-link
- v-if="!isApproving(row)"
- type="primary"
- :underline="false"
- @click="toBomManager(row)"
- >
- BOM
- </el-link>
- <el-link
- type="primary"
- :underline="false"
- @click="publish(row)"
- v-if="
- !isApproving(row) &&
- !isApprovePassed(row) &&
- row.isPublished != 1 &&
- $hasPermission('main:category:update')
- "
- >
- 发布
- </el-link>
- <!-- <el-link
- type="primary"
- v-if="row.isProduct == 1"
- :underline="false"
- @click="openMaterial(row)"
- >
- 物料BOM
- </el-link> -->
- <!-- <el-link
- type="primary"
- v-if="row.isProduct == 1"
- :underline="false"
- @click="openMould(row)"
- >
- 模具
- </el-link> -->
- <el-link
- type="primary"
- v-if="!isApproving(row) && row.categoryLevelPathIdParent == 7"
- :underline="false"
- @click="handAllocation(row)"
- >
- 货位
- </el-link>
- <el-link
- type="primary"
- v-if="!isApproving(row) && row.categoryLevelPathIdParent == 11"
- :underline="false"
- @click="handleAridRegion(row)"
- >
- 干燥区
- </el-link>
- </template>
- </ele-pro-table>
- <!-- 编辑弹窗 -->
- <!-- <dict-edit :visible.sync="showEdit" :id="id" @done="reload" /> -->
- <!-- 选择物料 -->
- <MaterialModal
- :visible.sync="materialEdit"
- :data="current"
- ref="materialRefs"
- ></MaterialModal>
- <!-- 工艺参数 -->
- <ParamEdit
- :visible.sync="paramEditShow"
- :paramData="current"
- ref="paramRefs"
- ></ParamEdit>
- <!-- 模具 -->
- <mouldDialog
- :visible.sync="mouldShow"
- :data="current"
- ref="mouldRefs"
- ></mouldDialog>
- <linkMaterialDialog ref="linkMaterialDialogRef" @success="success" />
- <!-- 货位 -->
- <goodsAllocation ref="allocationRef"></goodsAllocation>
- <!-- 干燥区 -->
- <aridRegion ref="aridRegionRef"></aridRegion>
- <!-- 导入错误弹框 -->
- <el-dialog
- title="导入失败"
- :visible.sync="exportErrorDioalogVisible"
- width="60%"
- >
- <el-table :data="errorData" style="width: 100%">
- <el-table-column label="名称" prop="name"> </el-table-column>
- <el-table-column label="型号" prop="modeType"> </el-table-column>
- <el-table-column label="编号" prop="codeNo"> </el-table-column>
- <el-table-column label="物料组" prop="code"> </el-table-column>
- <el-table-column label="失败原因" prop="remark"> </el-table-column>
- </el-table>
- <span slot="footer" class="dialog-footer">
- <el-button @click="exportErrorDioalogVisible = false">取 消</el-button>
- <el-button type="primary" @click="exportErrorDioalogVisible = false"
- >确 定</el-button
- >
- </span>
- </el-dialog>
- <importDialog
- :defModule="moudleName"
- ref="importDialogRef"
- :fileUrl="'/main/category/downLoadTemplate'"
- fileName="产品_物品导入模板"
- @success="reload"
- />
- <!-- 产品管理 -->
- <BomDetailsPop ref="bomDrawer"></BomDetailsPop>
- <DialogMoveTo ref="DialogMoveToRef" @success="success"></DialogMoveTo>
- <warehouseDialog
- ref="warehouseDialogRef"
- @success="success"
- ></warehouseDialog>
- <process-submit-dialog
- :processSubmitDialogFlag.sync="processSubmitDialogFlag"
- v-if="processSubmitDialogFlag"
- ref="processSubmitDialogRef"
- :custom-submit="submitCategoryPublish"
- @reload="handleProcessReload"
- ></process-submit-dialog>
- </div>
- </template>
- <script>
- import {
- getMaterialList,
- removeMaterial,
- importCategorySparePart,
- exportFile,
- changeOnOff,
- publishCategory
- } from '@/api/material/list.js';
- import { getBomGetById } from '@/api/material/BOM.js';
- import MaterialModal from './MaterialModal.vue';
- import ParamEdit from '@/views/technology/productParam/components/user-edit.vue';
- import mouldDialog from './mouldDialog';
- import linkMaterialDialog from './link-material-dialog.vue';
- import goodsAllocation from './goodsAllocation.vue';
- import { parameterGetByCode } from '@/api/system/dictionary/index.js';
- import BomDetailsPop from '../../BOMmanage/detailsPop.vue';
- import dictMixins from '@/mixins/dictMixins';
- import aridRegion from './aridRegion';
- import importDialog from '@/components/upload/import-dialogNew.vue';
- import { fieldModel } from '@/api/codeManagement';
- import DialogMoveTo from './DialogMoveTo.vue';
- import warehouseDialog from './warehouseDialog.vue';
- import processSubmitDialog from '@/components/processSubmitDialog/processSubmitDialog.vue';
- import tabMixins from '@/mixins/tableColumnsMixin';
- import { produceTypeList } from '@/enum/dict.js';
- import request from '@/utils/request';
- import { download } from '@/utils/file';
- import { getByCode } from '@/api/system/dictionary-data';
- /*const attributeList = [
- {
- label: '总装',
- value: 1
- },
- {
- label: '部件',
- value: 2
- },
- {
- label: '零件',
- value: 3
- },
- {
- label: '原材料',
- value: 4
- }
- ];*/
- const measureTypeList = [
- {
- label: '数量',
- value: 1
- },
- {
- label: '重量',
- value: 2
- },
- {
- label: '体积',
- value: 3
- },
- {
- label: '容积',
- value: 4
- },
- {
- label: '面积',
- value: 5
- }
- ];
- export default {
- mixins: [dictMixins, tabMixins],
- components: {
- importDialog,
- MaterialModal,
- ParamEdit,
- mouldDialog,
- linkMaterialDialog,
- goodsAllocation,
- aridRegion,
- BomDetailsPop,
- DialogMoveTo,
- warehouseDialog,
- processSubmitDialog
- },
- props: {
- // 物料组id
- currentId: [Number, String],
- data: [Array, Object],
- rootId: [Number, String],
- rootTreeId: [Number, String],
- lyType: [String],
- oneProduct: Boolean,
- currentData: Object,
- //table-cacheKeyUrl
- cacheKeyUrl: String
- },
- data() {
- return {
- attributeList: [],
- exportLoading: false,
- moudleName: 'mainCategory',
- currentPage: 1,
- errorData: [],
- exportErrorDioalogVisible: false,
- pagination: {
- total: 0
- },
- bomShow: false,
- whereData: {},
- pageShow: false,
- // 表格列配置
- columns: [
- {
- width: 45,
- type: 'selection',
- columnKey: 'selection',
- align: 'center',
- selectable: (row) => !this.isApproving(row)
- },
- {
- columnKey: 'index',
- type: 'index',
- width: 50,
- align: 'center',
- showOverflowTooltip: true,
- label: '序号'
- },
- {
- prop: 'code',
- label: '编码',
- align: 'center',
- showOverflowTooltip: true,
- sortable: true,
- minWidth: 110,
- slot: 'code'
- },
- {
- prop: 'name',
- label: '名称',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 110,
- slot: 'name'
- },
- {
- prop: 'categoryLevelPath',
- label: '分类',
- align: 'center',
- showOverflowTooltip: true
- },
- // {
- // prop: 'categoryLevelPath',
- // label: 'BOM状态',
- // align: 'center',
- // showOverflowTooltip: true,
- // formatter: (row, column) => {
- // return row.isUnpack == 1 ? '是' : '否';
- // }
- // },
- {
- prop: 'brandNum',
- align: 'center',
- label: '牌号',
- showOverflowTooltip: true
- },
- {
- prop: 'modelType',
- label: '型号',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- prop: 'specification',
- label: '规格',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- prop: 'imgCode',
- label: '图号/件号',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- prop: 'level',
- label: '级别',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- prop: 'bomStatus',
- label: 'MBOM状态',
- align: 'center',
- minWidth: 120,
- formatter: (row, column) => {
- return row.bomStatus == 1 ? '有' : '无';
- },
- showOverflowTooltip: true
- },
- {
- prop: 'pBomStatus',
- label: 'PBOM状态',
- align: 'center',
- minWidth: 120,
- formatter: (row, column) => {
- return row.pbomStatus == 1 ? '有' : '无';
- },
- showOverflowTooltip: true
- },
- {
- prop: 'aBomStatus',
- label: 'ABOM状态',
- align: 'center',
- minWidth: 120,
- formatter: (row, column) => {
- return row.abomStatus == 1 ? '有' : '无';
- },
- showOverflowTooltip: true
- },
- {
- prop: 'isUnpack',
- label: '是否允许拆包',
- align: 'center',
- minWidth: 120,
- formatter: (row, column) => {
- return row.isUnpack == 1 ? '是' : '否';
- },
- showOverflowTooltip: true
- },
- {
- prop: 'isComeCheck',
- label: '是否采购来料检验',
- align: 'center',
- minWidth: 120,
- formatter: (row, column) => {
- return row.isComeCheck == 1 ? '是' : '否';
- },
- showOverflowTooltip: true
- },
- {
- prop: 'isOutsourcingCheck',
- label: '是否委外来料检验',
- align: 'center',
- minWidth: 120,
- formatter: (row, column) => {
- return row.isOutsourcingCheck == 1 ? '是' : '否';
- },
- showOverflowTooltip: true
- },
- {
- prop: 'measuringUnit',
- label: '计量单位',
- showOverflowTooltip: true,
- minWidth: 90
- },
- {
- prop: 'weightUnit',
- label: '重量单位',
- showOverflowTooltip: true,
- minWidth: 90
- },
- {
- prop: 'roughWeight',
- label: '毛重',
- showOverflowTooltip: true,
- minWidth: 90
- },
- {
- prop: 'netWeight',
- label: '净重',
- showOverflowTooltip: true,
- minWidth: 90
- },
- {
- prop: 'packingUnit',
- align: 'center',
- label: '包装单位',
- showOverflowTooltip: true
- },
- {
- prop: 'componentAttribute',
- slot: 'componentAttribute',
- align: 'center',
- label: '属性类型',
- showOverflowTooltip: true
- // formatter: (row, column) => {
- // return row?.produceType
- // ?.map((item) => {
- // {{row}}
- // return this.getDictValueFn(item);
- // })
- // ?.toString();
- // }
- },
- {
- prop: 'attributeType',
- align: 'center',
- label: '存货类型',
- showOverflowTooltip: true,
- formatter: (row, column) => {
- const item = this.attributeList.find(
- (item) => item[row.attributeType] !== undefined
- );
- return item ? item[row.attributeType] : null; // 如果找不到返回 null
- }
- },
- {
- prop: 'produceType',
- align: 'center',
- label: '生产类型',
- showOverflowTooltip: true,
- formatter: (row, column) => {
- return produceTypeList.find(
- (item) => item.value == row.produceType
- )?.label;
- }
- },
- {
- prop: 'measureType',
- align: 'center',
- label: '计量类型',
- showOverflowTooltip: true,
- formatter: (row, column) => {
- return measureTypeList.find(
- (item) => item.value == row.measureType
- )?.label;
- }
- },
- {
- prop: 'modelKey',
- label: '机型',
- align: 'center',
- minWidth: 150,
- showOverflowTooltip: true,
- formatter: (row, column) => {
- return row.modelKey
- ? row.modelKey
- .split(',')
- ?.map((item) => this.getDictValue('物品机型', item))
- .toString()
- : '';
- }
- },
- {
- prop: 'colorKey',
- label: '颜色',
- align: 'center',
- minWidth: 150,
- showOverflowTooltip: true,
- formatter: (row, column) => {
- return row.colorKey
- ? row.colorKey
- .split(',')
- ?.map((item) => this.getDictValue('物品颜色', item))
- .toString()
- : '';
- }
- },
- {
- prop: 'createTime',
- label: '创建时间',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- prop: 'createUserName',
- label: '创建人',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- prop: 'isPublished',
- label: '发布状态',
- align: 'center',
- minWidth: 100,
- formatter: (row, column) => {
- return row.isPublished == 1 ? '已发布' : '未发布';
- },
- showOverflowTooltip: true
- },
- {
- prop: 'approveStatus',
- label: '审核状态',
- align: 'center',
- minWidth: 100,
- slot: 'approveStatus',
- showOverflowTooltip: true
- },
- {
- prop: 'isEnabled',
- align: 'center',
- label: '状态',
- slot: 'isEnabled',
- showOverflowTooltip: true,
- fixed: 'right',
- formatter: (row, column) => {
- return row.isEnabled === 0
- ? '停用'
- : row.isEnabled === 1
- ? '启用'
- : '';
- }
- }
- ],
- sxtList: [
- {
- label: '自制件',
- value: 1
- },
- {
- label: '采购件',
- value: 2
- },
- {
- label: '外协件',
- value: 3
- },
- {
- label: '受托件',
- value: 4
- }
- ],
- // newColumns: [],
- // 表格选中数据
- selection: [],
- // 是否显示编辑弹窗
- showEdit: false,
- id: null,
- materialEdit: false,
- paramEditShow: false,
- mouldShow: false,
- current: null,
- rowCurrent: null,
- isLoading: false,
- pageSize: this.$store.state.tablePageSize,
- isBatchPublish: true,
- processSubmitDialogFlag: false
- };
- },
- created: function () {
- getByCode('inventory_type').then((res) => {
- if (res.code === '0') {
- this.attributeList = res.data;
- }
- });
- this.getCategoryNeedApprove();
- // this.requestDict('生产类型');
- this.requestDict('物品机型');
- this.requestDict('物品颜色');
- this.getFieldModel();
- },
- activated() {
- this.getCategoryNeedApprove();
- },
- methods: {
- getCategoryNeedApprove() {
- return parameterGetByCode({
- code: 'category_need_approve'
- }).then((res) => {
- console.log(res.value, 'category_need_approve');
- this.isBatchPublish = res.value == 1 ? true : false;
- });
- },
- async changeEnable(row) {
- const res = await changeOnOff(row.id);
- if (res.code == 0) {
- this.$message({
- type: 'success',
- message: '修改成功',
- customClass: 'ele-message-border'
- });
- this.reload();
- }
- },
- onSortChange(e) {
- console.log(e, '99999999');
- let sort = {
- orderBy: e.order,
- sortName: e.prop
- };
- this.sort = sort;
- this.reload();
- },
- getDictValueFn(e) {
- // console.log(e,'3333333333333');
- if (e.length) {
- let arr = [];
- e.map((v) => {
- arr.push(this.findFn(v)?.label);
- });
- return arr.join(',');
- } else {
- return '';
- }
- // let a =
- // return a?.label||''
- },
- findFn(e) {
- return this.sxtList.find((item) => item.value == Number(e));
- },
- toBomManager(row) {
- let rowData = {
- categoryId: row.id,
- categoryName: row.name,
- code: row.code,
- rootPathIdParent: row.categoryLevelPathIdParent,
- isProduct: row.isProduct == 1
- };
- this.$refs.bomDrawer.open(rowData);
- },
- //采购
- moveTo() {
- if (this.hasApprovingSelection()) {
- return;
- }
- this.$refs.DialogMoveToRef.open(this.selection);
- },
- //仓库
- warehouseOpen() {
- if (this.hasApprovingSelection()) {
- return;
- }
- this.$refs.warehouseDialogRef.open(this.selection);
- },
- successUpload(response) {
- this.isLoading = false;
- },
- errorUpload(response) {
- this.isLoading = false;
- },
- // 上传备品备件
- beforeUpload(file) {
- if (file.size / 1024 / 1024 > this.size) {
- this.$message.error(`大小不能超过 ${this.size}MB`);
- return false;
- }
- if (this.limit > 0 && this.fileList.length === this.limit) {
- this.$message.error(`最多上传 ${this.limit}个文件`);
- return false;
- }
- let formData = new FormData();
- formData.append('file', file);
- this.isLoading = true;
- return importCategorySparePart(formData).then((res) => {
- if (res.data.length > 0) {
- this.exportErrorDioalogVisible = true;
- this.errorData = res.data;
- } else {
- this.$message.success('导入成功!');
- }
- this.isLoading = false;
- return false;
- });
- },
- /* 表格数据源 */
- hasCurrentCategory() {
- return (
- this.currentId !== undefined &&
- this.currentId !== null &&
- this.currentId !== ''
- );
- },
- getCategoryParams(params = {}) {
- return {
- ...params,
- categoryLevelId: this.currentId
- };
- },
- async datasource({ page, limit, where, order }) {
- this.currentPage = page;
- if (!this.hasCurrentCategory()) {
- return {
- pageNum: page,
- current: page,
- size: limit,
- count: 0,
- list: []
- };
- }
- const params = this.getCategoryParams({
- pageNum: page,
- size: limit,
- ...this.sort,
- ...where
- });
- this.whereData = params;
- return getMaterialList(params);
- },
- /* 刷新表格 */
- reload(where) {
- if (!this.hasCurrentCategory()) {
- return;
- }
- let labs = this.getCategoryParams({
- page: 1,
- where: where
- });
- this.whereData = labs;
- this.$refs.table.reload(
- this.getCategoryParams({
- page: 1,
- where: where
- })
- );
- },
- /* 刷新表格 */
- reloadNew(where) {
- if (!this.hasCurrentCategory()) {
- return;
- }
- let labs = this.getCategoryParams({
- page: 1,
- where: where
- });
- this.whereData = labs;
- this.$refs.table.reload(
- this.getCategoryParams({
- page: this.currentPage,
- where: where
- })
- );
- },
- getFieldModel() {
- fieldModel({ relevance: 't_main_category' }).then((res) => {
- const privateColumn = [
- {
- columnKey: 'action',
- label: '操作',
- width: 300,
- align: 'center',
- resizable: false,
- slot: 'action',
- fixed: 'right'
- }
- ];
- let newRes = res.map((m) => {
- return {
- prop: 'extField.' + m.prop,
- label: m.label,
- align: 'center',
- showOverflowTooltip: true
- };
- });
- this.columns = [...this.columns, ...newRes, ...privateColumn];
- this.getTabColumns();
- this.$forceUpdate();
- });
- },
- publish(row) {
- if (this.isBatchPublish) {
- this.submitApprove(row);
- return;
- }
- const loading = this.$loading({ lock: true });
- publishCategory({ categoryId: row.id })
- .then((res) => {
- this.$message.success(res.message || '发布成功');
- this.reloadNew();
- })
- .finally(() => {
- loading.close();
- });
- },
- submitApprove(row) {
- if (!row || !row.id) {
- return;
- }
- this.processSubmitDialogFlag = true;
- this.$nextTick(() => {
- const userInfo = this.$store.state.user.info || {};
- const params = {
- businessId: row.id,
- businessKey: 'category_need_approve',
- formCreateUserId: row.createUserId || userInfo.userId || userInfo.id,
- variables: {
- businessCode: row.code,
- businessName: row.name,
- businessType: this.getCategoryBusinessType(row)
- }
- };
- this.$refs.processSubmitDialogRef.init(params);
- });
- },
- getCategoryBusinessType(row) {
- return row.categoryLevelPath || row.categoryName || '物品发布';
- },
- submitCategoryPublish(businessId, form) {
- return publishCategory({
- categoryId: businessId,
- ...form
- });
- },
- handleProcessReload() {
- this.reloadNew();
- },
- /* 显示编辑 */
- batchPublish() {
- if (!this.selection.length) {
- this.$message.warning('请先勾选要发布的数据');
- return;
- }
- if (this.hasApprovingSelection()) {
- return;
- }
- const publishedList = this.selection.filter((item) => item.isPublished == 1);
- if (publishedList.length) {
- const publishedNames = publishedList
- .map((item) => item.name || item.code || item.categoryId || item.id)
- .filter(Boolean)
- .join('、');
- this.$message.warning(
- `勾选的数据中【${publishedNames}】已发布,不能继续发布`
- );
- return;
- }
- const categoryIds = this.selection
- .map((item) => item.categoryId || item.id)
- .filter((id) => id !== undefined && id !== null && id !== '');
- if (!categoryIds.length) {
- this.$message.warning('未获取到可发布数据');
- return;
- }
- this.$confirm(`确定要发布选中的 ${categoryIds.length} 条数据吗?`, '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- })
- .then(() => {
- const loading = this.$loading({ lock: true });
- publishCategory({ categoryIds })
- .then((res) => {
- this.$message.success(res.message || '发布成功');
- this.reloadNew();
- })
- .finally(() => {
- loading.close();
- });
- })
- .catch(() => {
- // 用户取消发布
- });
- },
- openEdit(row, status) {
- console.log(status, this.currentData, 'status');
- let isUpdate;
- let readOnly = false;
- if (status == 2) {
- isUpdate = 0;
- } else if (status == 3) {
- // 详情模式:只读
- isUpdate = 0;
- readOnly = true;
- } else {
- isUpdate = 1;
- }
- this.$router.push({
- path: '/material/product/detail',
- query: {
- lyType: this.lyType,
- id: row.id ? row.id : null,
- status: status,
- rootId: this.rootId,
- isUpdate: isUpdate,
- readOnly: readOnly,
- oneProduct: this.oneProduct,
- t: new Date().getTime(),
- rootTreeId: this.rootTreeId,
- ...this.currentData
- }
- });
- },
- /* 删除 */
- remove(row) {
- const loading = this.$loading({ lock: true });
- removeMaterial(row.id)
- .then((msg) => {
- this.$refs.table.reload({
- page: 1,
- categoryLevelId: this.currentId
- });
- loading.close();
- })
- .catch((e) => {
- loading.close();
- });
- },
- openMaterial(row) {
- this.current = row;
- this.materialEdit = true;
- this.$refs.materialRefs.$refs.form &&
- this.$refs.materialRefs.$refs.form.clearValidate();
- },
- openParam(row) {
- this.paramEditShow = true;
- this.current = row;
- this.$refs.paramRefs.$refs.form &&
- this.$refs.paramRefs.$refs.form.clearValidate();
- },
- openMould(row) {
- this.current = row;
- this.mouldShow = true;
- this.$refs.mouldRefs.$refs.form &&
- this.$refs.mouldRefs.$refs.form.clearValidate();
- },
- handleLink(type) {
- if (!this.rowCurrent) {
- return this.$message.error(
- this.rootTreeId == 9
- ? '请选择产品!'
- : this.rootTreeId == 4
- ? '请选择设备!'
- : ''
- );
- }
- this.$refs.linkMaterialDialogRef.open(type, this.rowCurrent);
- },
- success() {
- this.reload();
- },
- hasApproveStatus(row) {
- return (
- row &&
- Object.prototype.hasOwnProperty.call(row, 'approveStatus') &&
- row.approveStatus !== null &&
- row.approveStatus !== undefined &&
- row.approveStatus !== ''
- );
- },
- isApproving(row) {
- if (!this.hasApproveStatus(row)) {
- return false;
- }
- return Number(row.approveStatus) === 1 || row.approveStatus === '审核中';
- },
- isApprovePassed(row) {
- if (!this.hasApproveStatus(row)) {
- return false;
- }
- return Number(row.approveStatus) === 2 || row.approveStatus === '已审核';
- },
- hasApprovingSelection() {
- if (this.selection.some((item) => this.isApproving(item))) {
- this.$message.warning('审核中的数据只能查看详情');
- return true;
- }
- return false;
- },
- getApproveStatusTagType(row) {
- if (!this.hasApproveStatus(row)) {
- return '';
- }
- return (
- {
- 0: 'info',
- 1: 'warning',
- 2: 'success',
- 3: 'danger'
- }[Number(row.approveStatus)] || ''
- );
- },
- getApproveStatusText(row) {
- if (!this.hasApproveStatus(row)) {
- return '';
- }
- return {
- 0: '未提交',
- 1: '审核中',
- 2: '已审核',
- 3: '审核不通过'
- }[Number(row.approveStatus)] || row.approveStatus;
- },
- handAllocation(row) {
- this.$refs.allocationRef.open(row);
- },
- handleAridRegion(row) {
- this.$refs.aridRegionRef.open(row);
- },
- uploadFile() {
- this.$refs.importDialogRef.open();
- },
- /** 导出按钮操作 */
- handleExport() {
- const data = this.whereData;
- if (!data || Object.keys(data).length === 0 || !data.categoryLevelId) {
- this.$message.warning('请选择物品类别');
- return;
- }
- this.exportLoading = true;
- request
- .post('/main/category/export', data, {
- responseType: 'blob'
- })
- .then((res) => {
- debugger;
- download(res.data, '产品/物品数据.xlsx');
- })
- .catch((e) => {
- console.error(e);
- })
- .finally(() => {
- this.exportLoading = false;
- });
- /*exportFile(this.whereData);
- console.log(this.whereData, 'whereForm');*/
- },
- /** 下载模板操作 */
- importTemplate() {
- importTemplate(this.whereForm).then((res) => {
- this.$message.success('模板下载成功');
- });
- }
- },
- watch: {
- // 监听物料组id变化
- currentId() {
- if (this.hasCurrentCategory()) {
- this.reload();
- }
- },
- $route: {
- handler(route) {
- this.pageShow = false;
- if (route.query && route.query.isWt) {
- getBomGetById(route.query.businessId).then((res) => {
- let rowData = {
- categoryId: res.data.categoryId,
- categoryName: res.data.name,
- code: res.data.categoryCode,
- rootPathIdParent: res.data.rootCategoryLevelId,
- isProduct: res.data.rootCategoryLevelId == 9 ? true : false,
- versions: res.data.versions,
- bomType: res.data.bomType,
- isWt: true,
- isBtn: route.query.isBtn
- };
- this.$nextTick(() => {
- this.$refs.bomDrawer.open(rowData);
- this.pageShow = true;
- });
- });
- } else {
- this.pageShow = true;
- }
- },
- immediate: true
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- .upload {
- display: inline-block;
- width: 100px;
- margin-left: 10px;
- }
- </style>
|