| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544 |
- <template>
- <div>
- <!-- 数据表格 -->
- <ele-pro-table
- ref="table"
- :columns="newColumns"
- :datasource="datasource"
- :need-page="true"
- :selection.sync="selection"
- :current.sync="rowCurrent"
- highlight-current-row
- height="calc(100vh - 412px)"
- full-height="calc(100vh - 116px)"
- tool-class="ele-toolbar-form"
- cache-key="systemDictDataTable"
- >
- <!-- 表头工具栏 -->
- <template v-slot:toolbar>
- <el-button
- size="small"
- type="primary"
- icon="el-icon-plus"
- class="ele-btn-icon"
- @click="openEdit({}, 2)"
- >
- 新建
- </el-button>
- <el-button
- type="primary"
- size="mini"
- icon="el-icon-upload2"
- plain
- @click="uploadFile"
- >导入</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:action="{ row }">
- <el-link type="primary" :underline="false" @click="openEdit(row, 1)">
- 复制
- </el-link>
- <el-link type="primary" :underline="false" @click="openEdit(row, 0)">
- 修改
- </el-link>
- <el-popconfirm
- class="ele-action"
- title="确定要删除此物料吗?"
- @confirm="remove(row)"
- >
- <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
- type="primary"
- v-if="row.isProduct == 1"
- :underline="false"
- @click="toBomManager(row)"
- >
- 结构BOM
- </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="row.categoryLevelPathIdParent == 7"
- :underline="false"
- @click="handAllocation(row)"
- >
- 货位
- </el-link>
- <el-link
- type="primary"
- v-if="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"
- @success="reload"
- />
- </div>
- </template>
- <script>
- import {
- getMaterialList,
- removeMaterial,
- importCategorySparePart
- } from '@/api/material/list.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 aridRegion from './aridRegion';
- import importDialog from '@/components/upload/import-dialog.vue';
- import { fieldModel } from '@/api/codeManagement';
- export default {
- components: {
- importDialog,
- MaterialModal,
- ParamEdit,
- mouldDialog,
- linkMaterialDialog,
- goodsAllocation,
- aridRegion
- },
- props: {
- // 物料组id
- currentId: [Number, String],
- data: [Array, Object],
- rootId: [Number, String],
- rootTreeId: [Number, String],
- oneProduct: Boolean
- },
- data() {
- return {
- moudleName : "mainCategory",
- errorData: [],
- exportErrorDioalogVisible: false,
- // 表格列配置
- columns: [
- {
- columnKey: 'index',
- type: 'index',
- width: 50,
- align: 'center',
- showOverflowTooltip: true,
- label: '序号'
- },
- {
- prop: 'code',
- label: '编码',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 110
- },
- {
- prop: 'name',
- label: '名称',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 110
- },
- {
- prop: 'brandNum',
- align: 'center',
- label: '牌号',
- showOverflowTooltip: true
- },
- {
- prop: 'modelType',
- label: '型号',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- prop: 'specification',
- label: '规格',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- prop: 'level',
- label: '级别',
- align: 'center',
- 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: 'categoryLevelPath',
- label: '分类',
- align: 'center',
- showOverflowTooltip: true
- },
-
- ],
- newColumns: [],
- // 表格选中数据
- selection: [],
- // 是否显示编辑弹窗
- showEdit: false,
- id: null,
- materialEdit: false,
- paramEditShow: false,
- mouldShow: false,
- current: null,
- rowCurrent: null,
- isLoading: false
- };
- },
- created() {
- this.getFieldModel();
- },
- methods: {
- toBomManager(row) {
- this.$router.push({
- path: '/material/BOMmanage/details',
- query: {
- categoryId: row.id,
- code: row.code
- }
- });
- },
- 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;
- });
- },
- /* 表格数据源 */
- datasource({ page, limit, where, order }) {
- return getMaterialList({
- pageNum: page,
- size: limit,
- ...where,
- categoryLevelId: this.currentId
- });
- },
- /* 刷新表格 */
- reload(where) {
- this.$refs.table.reload({
- page: 1,
- where: where,
- categoryLevelId: this.currentId
- });
- },
- getFieldModel() {
- fieldModel({ fieldModel: 't_main_category' }).then((res) => {
- const privateColumn = [
- {
- columnKey: 'action',
- label: '操作',
- width: 220,
- 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.newColumns = [...this.columns, ...newRes, ...privateColumn];
- this.$forceUpdate();
- });
- },
- /* 显示编辑 */
- openEdit(row, status) {
- this.$router.push({
- path: '/material/product/detail',
- query: {
- id: row.id ? row.id : null,
- status: status,
- rootId: this.rootId,
- oneProduct: this.oneProduct,
- t: new Date().getTime()
- }
- });
- },
- /* 删除 */
- remove(row) {
- const loading = this.$loading({ lock: true });
- removeMaterial(row.id)
- .then((msg) => {
- loading.close();
- this.$message.success('删除' + msg);
- this.reload();
- })
- .catch((e) => {
- loading.close();
- // this.$message.error(e.message);
- });
- },
- 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();
- },
- handAllocation(row) {
- this.$refs.allocationRef.open(row);
- },
- handleAridRegion(row) {
- this.$refs.aridRegionRef.open(row);
- },
- uploadFile () {
- this.$refs.importDialogRef.open();
- }
- },
- watch: {
- // 监听物料组id变化
- currentId() {
- this.reload();
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- .upload {
- display: inline-block;
- width: 100px;
- margin-left: 10px;
- }
- </style>
|