| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720 |
- <template>
- <div class="workmanship">
- <el-card shadow="never">
- <el-form
- label-width="77px"
- class="ele-form-search"
- @keyup.enter.native="search"
- @submit.native.prevent
- >
- <el-row type="flex" :gutter="24">
- <el-col :span="6">
- <el-form-item label="工序编码:" label-width="100px">
- <el-input
- clearable
- v-model.trim="where.code"
- placeholder="请输入"
- />
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="工序名称:" label-width="100px">
- <el-input
- clearable
- v-model.trim="where.name"
- placeholder="请输入"
- />
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="所属工作中心" label-width="100px">
- <el-input
- clearable
- v-model.trim="where.workCenterName"
- placeholder="请输入"
- />
- </el-form-item>
- </el-col>
- <el-col :span="4">
- <div class="ele-form-actions">
- <el-button
- type="primary"
- class="ele-btn-icon"
- size="small"
- @click="reload"
- >
- 查询
- </el-button>
- <el-button size="small" plain>重置</el-button>
- </div>
- </el-col>
- </el-row>
- </el-form>
- <!-- 数据表格 -->
- <ele-pro-table
- class="table_list"
- ref="table"
- :columns="columns"
- :datasource="datasource"
- :need-page="false"
- row-key="id"
- >
- <!-- 表头工具栏 -->
- <!-- <template v-slot:toolbar>
- <el-button
- v-if="attributeData.status != 1"
- size="small"
- type="primary"
- icon="el-icon-plus"
- class="ele-btn-icon"
- @click="openEdit()"
- >
- 添加工序
- </el-button>
- </template> -->
- <!-- 展开内容 -->
- <template v-slot:expand="{ row, $index }">
- <div
- style="width: 100%; min-height: 60px"
- v-if="row.categoryParamStepList"
- >
- <ele-pro-table
- :toolbar="false"
- toolsTheme="none"
- ref="table2"
- :need-page="false"
- :datasource="row.categoryParamStepList"
- :columns="columns2"
- :key="row.code + '-' + $index"
- >
- <template v-slot:sort="{ row }">
- <el-input
- @input="(e) => validateNumber(e, row)"
- v-model.number="row.sort"
- ></el-input>
- </template>
- <!-- 默认值 -->
- <!-- <template v-slot:defaultValue="{ row }">
- <el-input
- v-if="
- row.textType == 1 || row.textType == 4 || row.textType == 5
- "
- v-model="row.defaultValue"
- placeholder="请输入"
- ></el-input>
- <el-select
- v-if="row.textType == 2"
- v-model="row.defaultValue"
- placeholder="请选择"
- >
- <el-option label="TRUE" :value="'TRUE'" />
- <el-option label="FALSE" :value="'FALSE'" />
- </el-select>
- </template> -->
- <template v-slot:name="{ row }">
- <el-input v-model="row.name" placeholder="请输入"></el-input>
- </template>
- <template v-slot:defaultValue="{ row }">
- <el-input
- v-model="row.defaultValue"
- placeholder="请输入"
- ></el-input>
- </template>
- <!-- 操作列 -->
- <template v-slot:action="{ row }">
- <!-- <el-link
- type="primary"
- :underline="false"
- icon="el-icon-edit"
- @click="editWorkingStep(row)"
- >
- 修改
- </el-link> -->
- <el-link
- type="primary"
- :underline="false"
- icon="el-icon-house"
- @click="saveWorking(row)"
- >
- 保存
- </el-link>
- <el-link
- type="primary"
- :underline="false"
- icon="el-icon-view"
- @click="openStepConfigure(row, true)"
- >
- 详情
- </el-link>
- <!-- <el-link
- type="primary"
- :underline="false"
- icon="el-icon-setting"
- @click="openStepConfigure(row)"
- >
- 配置
- </el-link> -->
- <el-popconfirm
- class="ele-action"
- title="确定要删除当前参数吗?"
- @confirm="remove2(row)"
- >
- <template v-slot:reference>
- <el-link
- type="danger"
- :underline="false"
- icon="el-icon-delete"
- >
- 删除
- </el-link>
- </template>
- </el-popconfirm>
- </template>
- </ele-pro-table>
- </div>
- </template>
- <!-- 操作列 -->
- <template v-slot:action="{ row }">
- <!-- <el-link
- type="primary"
- :underline="false"
- icon="el-icon-edit"
- @click="editWorkingProcedure(row)"
- v-if="attributeData.status != 1"
- >
- 修改
- </el-link> -->
- <el-link
- type="primary"
- :underline="false"
- icon="el-icon-view"
- @click="openConfigure(row, true)"
- >
- 详情
- </el-link>
- <el-link
- type="primary"
- :underline="false"
- icon="el-icon-setting"
- @click="openStepSetting(row)"
- v-if="attributeData.status != 1"
- >
- 工步
- </el-link>
- <el-link
- type="primary"
- :underline="false"
- icon="el-icon-setting"
- v-if="
- attributeData.approvalStatus != 2 &&
- attributeData.approvalStatus != 1
- "
- @click="openConfigure(row)"
- >
- 配置
- </el-link>
- <!-- <el-popconfirm
- class="ele-action"
- title="确定要删除当前工序吗?"
- @confirm="remove(row)"
- >
- <template v-slot:reference>
- <el-link v-if="attributeData.status != 1" type="danger" :underline="false" icon="el-icon-delete">
- 删除
- </el-link>
- </template>
- </el-popconfirm> -->
- </template>
- </ele-pro-table>
- </el-card>
- <ProcessModal
- ref="processModalRef"
- @chooseProcess="chooseProcess"
- ></ProcessModal>
- <ParamModal ref="paramRefs" @chooseModal="chooseModal"></ParamModal>
- <StepModal ref="stepModalRefs" @chooseModal="chooseStepModal"></StepModal>
- <workingProcedure
- ref="workingProcedureRef"
- @chooseProcess="chooseProcess"
- ></workingProcedure>
- <workingStep
- ref="workingStepRef"
- @chooseProcess="chooseProcess"
- ></workingStep>
- <user-edit
- :visible.sync="showEdit"
- :data="current"
- :controlList="controlList"
- :isView="isView"
- @done="reload"
- ref="userEdit"
- :typeList="typeList"
- />
- </div>
- </template>
- <script>
- import {
- workingProcedureUpdate,
- getStepListById,
- workingStepSave,
- workingSingleUpdate
- } from '@/api/material/BOM';
- import ProcessModal from './processModal.vue';
- import ParamModal from './ParamModal.vue';
- import StepModal from './StepModal1.vue';
- import workingProcedure from './workingProcedure.vue';
- import workingStep from './workingStep.vue';
- import { getMbomPage, workingStepDelete } from '@/api/material/BOM';
- import control from '@/api/technology/control';
- import UserEdit from '@/views/technology/stepManagement/components/user-edit.vue';
- export default {
- name: 'process',
- components: {
- ProcessModal,
- ParamModal,
- workingProcedure,
- StepModal,
- workingStep,
- UserEdit
- },
- props: {
- // bom bomCategoryId
- resourceBomId: String,
- // bom 信息
- taskParam: Object,
- // bom 信息 和 taskParam是一样的
- attributeData: {
- type: Object,
- default: {}
- }
- },
- watch: {
- attributeData: {
- handler(val) {
- this.$nextTick(() => {
- this.reload();
- });
- },
- deep: true,
- immediate: true
- }
- },
- data() {
- return {
- // 表格列配置
- columns: [
- {
- width: 45,
- type: 'expand',
- columnKey: 'categoryParamStepList',
- align: 'center',
- slot: 'expand',
- className: ''
- },
- {
- prop: 'sort',
- label: '排序号',
- showOverflowTooltip: true,
- align: 'center',
- minWidth: 110
- },
- {
- prop: 'code',
- label: '工序编码',
- showOverflowTooltip: true,
- align: 'center',
- minWidth: 110
- },
- {
- prop: 'name',
- label: '工序名称',
- showOverflowTooltip: true,
- align: 'center',
- minWidth: 110
- },
- {
- align: 'center',
- prop: 'controlName',
- label: '工序控制码',
- showOverflowTooltip: true,
- minWidth: 110
- },
- {
- prop: 'workCenterName',
- label: '所属工作中心',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 110
- },
- {
- columnKey: 'action',
- label: '操作',
- width: 300,
- align: 'center',
- resizable: false,
- slot: 'action',
- showOverflowTooltip: true
- }
- ],
- // 表格列配置
- columns2: [
- {
- prop: 'sort',
- slot: 'sort',
- label: '排序',
- minWidth: 60
- },
- {
- prop: 'code',
- label: '工步编码',
- showOverflowTooltip: true,
- align: 'center',
- minWidth: 110
- },
- {
- prop: 'name',
- slot: 'name',
- label: '工步名称',
- showOverflowTooltip: true,
- align: 'center',
- minWidth: 110
- },
- {
- slot: 'defaultValue',
- prop: 'defaultValue',
- label: '工序内容',
- showOverflowTooltip: true,
- align: 'center',
- minWidth: 110
- },
- {
- prop: 'status',
- slot: 'status',
- label: '状态',
- align: 'center',
- showOverflowTooltip: true,
- formatter: (_row) => {
- return ['生效', '失效'][_row.status];
- }
- },
- {
- columnKey: 'action',
- label: '操作',
- align: 'center',
- resizable: false,
- slot: 'action',
- minWidth: 200,
- showOverflowTooltip: true
- }
- ],
- processData: [],
- removeList: [],
- where: {},
- currentTableData: [],
- typeList: [
- {
- value: 1,
- label: '普通工步'
- },
- {
- value: 2,
- label: '抽样质检工步'
- },
- {
- value: 3,
- label: '普通质检工步'
- },
- {
- value: 4,
- label: '包装工步'
- },
- {
- value: 5,
- label: '入库工步'
- },
- {
- value: 6,
- label: '一工一检(常规质检)'
- }
- ],
- showEdit: false,
- current: null,
- isView: false,
- controlList: []
- };
- },
- methods: {
- // 单个工步数据保存
- saveWorking(row) {
- if (!row.name) {
- this.$message.warning('请输入工步名称');
- return;
- }
- if (!row.sort) {
- this.$message.warning('请输入工步排序');
- return;
- }
- let data = {
- stepName: row.name,
- id: row.id,
- defaultValue: row.defaultValue,
- sort: row.sort
- };
- workingSingleUpdate(data)
- .then((res) => {
- if (res.data) {
- this.$message.success('保存成功');
- } else {
- this.$message.error('保存失败');
- }
- })
- .catch((err) => {
- console.log(err, 'err');
- });
- },
- validateNumber(e, row) {
- if (e == 0) {
- row.sort = '';
- return;
- }
- let value = '';
- value = e.replace(/[^\d]/g, '');
- if (value.startsWith('0') && value.length > 1) {
- value = value.replace(/^0+/, '');
- }
- row.sort = value;
- },
- // expandChange(row, rows) {
- // if (rows.length > 0) {
- // // 展开
- // console.log('展开');
- // getStepListById({
- // paramId: row.id,
- // bomCategoryId: this.taskParam.id
- // }).then((data) => {
- // row.produceList = data;
- // });
- // }
- // console.log(row);
- // console.log(rows);
- // },
- openConfigure(row, isView) {
- this.$refs.workingProcedureRef.open(
- row,
- this.taskParam,
- this.currentTableData,
- !!isView,
- this.attributeData,
- this.resourceBomId
- );
- },
- openStepConfigure(row, isView) {
- console.log('123123123', row);
- // this.$refs.workingStepRef.open(row, this.taskParam, !!isView);
- this.isView = !!isView;
- this.getControlList();
- this.current = row;
- this.showEdit = true;
- this.$refs.userEdit.$refs.form &&
- this.$refs.userEdit.$refs.form.clearValidate();
- },
- getControlList() {
- const params = {
- pageNum: 1,
- size: -1
- };
- control.list().then((res) => {
- this.controlList = res.list;
- });
- },
- search() {},
- /*配置工艺参数 */
- openSetting(row) {
- this.current = row;
- this.$refs.paramRefs.open(row.produceList, this.current);
- },
- openStepSetting(row) {
- getStepListById({
- paramId: row.id,
- bomCategoryId: this.taskParam.id
- }).then((data) => {
- this.$refs.stepModalRefs.open(data, row, '新增');
- });
- },
- /* 表格数据源 */
- async datasource({ page, limit, where }) {
- let data = await getMbomPage({
- ...where,
- bomCategoryId: this.resourceBomId,
- categoryCode: this.attributeData.categoryCode,
- pageNum: page,
- size: limit
- });
- if (data?.length > 0) {
- this.currentTableData = data[0];
- let dataList = [];
- if (data[0].taskParam.length != 0) {
- dataList = data[0].taskParam.sort(
- (it, ie) => Number(it.sort) - Number(ie.sort)
- );
- }
- return dataList;
- // return data[0].taskParam;
- } else {
- return [];
- }
- },
- editWorkingProcedure(row) {
- this.$refs.processModalRef.open(
- this.taskParam,
- this.currentTableData,
- '修改',
- row
- );
- },
- openEdit() {
- this.$refs.processModalRef.open(
- this.taskParam,
- this.currentTableData,
- '新增'
- );
- },
- editWorkingStep(row) {
- this.$refs.stepModalRefs.open([], row, '修改');
- },
- reload(where) {
- this.$refs.table.reload({ where });
- },
- chooseProcess(data) {
- // let _arr = [...data, ...this.$refs.table.getData()];
- // this.$refs.table.setData([...data, ...this.$refs.table.getData()]);
- // this.$emit('chooseProcess', _arr);
- this.reload();
- },
- chooseModal(data, current) {
- data.map((m) => {
- m.parentId = current.id;
- return {
- ...m
- };
- });
- let tableList = [];
- let clonedArray = [];
- tableList = this.$refs.table.getData();
- clonedArray = JSON.parse(JSON.stringify(tableList));
- clonedArray.forEach((e) => {
- if (e.id == current.id) {
- if (e.hasOwnProperty('produceList')) {
- e.produceList = [...e.produceList, ...data];
- } else {
- e.produceList = [...data];
- }
- }
- });
- this.$refs.table.setData([...clonedArray]);
- this.$emit('chooseProcess', clonedArray);
- this.$nextTick(() => {
- this.$refs.table.toggleRowExpansionAll();
- this.$forceUpdate();
- });
- },
- chooseStepModal(data, current) {
- if (data?.length > 0) {
- let params = data.map((item) => {
- const itemData = {
- ...item,
- paramId: current.id,
- stepId: item.id,
- categoryId: this.taskParam.categoryId,
- bomCategoryId: this.taskParam.id,
- categoryCode: this.taskParam.categoryCode
- };
- itemData.type = item.type.code;
- return itemData;
- });
- workingStepSave(params).then((data) => {
- this.$message.success('保存成功');
- this.reload();
- });
- }
- // this.reload();
- console.log(data);
- console.log(current);
- },
- /* 删除 */
- remove(row) {
- workingProcedureUpdate({
- id: this.currentTableData.id,
- categoryId: this.taskParam.categoryId,
- bomCategoryId: this.taskParam.id,
- categoryCode: this.taskParam.categoryCode,
- taskParam: this.currentTableData.taskParam.filter(
- (item) => item.id !== row.id
- )
- }).then((data) => {
- this.$message.success('删除成功');
- this.reload();
- });
- },
- remove2(row) {
- workingStepDelete([row.id]).then(() => {
- this.$message.success('删除成功');
- this.reload();
- });
- this.$forceUpdate();
- }
- }
- };
- </script>
- <style lang="scss">
- .workmanship {
- height: 100%;
- .el-card {
- height: 100%;
- .el-card__body {
- height: 100%;
- display: flex;
- flex-direction: column;
- overflow: auto;
- .table_list {
- flex: 1;
- display: flex;
- flex-direction: column;
- .el-table {
- flex: 1;
- overflow-y: auto !important;
- display: flex;
- flex-direction: column;
- .el-table__body-wrapper {
- flex: 1;
- }
- }
- }
- }
- }
- }
- </style>
|