| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285 |
- <!-- 用户编辑弹窗 -->
- <template>
- <ele-modal
- width="1060px"
- :visible="visible"
- :append-to-body="true"
- :close-on-click-modal="false"
- custom-class="ele-dialog-form"
- title="工序"
- @update:visible="updateVisible(false)"
- >
- <header-title title="基本信息"> </header-title>
- <el-form ref="form" :model="form" :rules="rules" label-width="100px">
- <el-row>
- <el-col :span="8">
- <el-form-item label="加工方式:" prop="produceType">
- <el-select
- v-model="form.produceType"
- style="width: 100%"
- @change="changeProduceType"
- >
- <el-option
- v-for="item of producedList"
- :key="item.code"
- :label="item.name"
- :value="item.code"
- ></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="BOM版本:" prop="bomCategoryId">
- <el-select
- v-model="form.bomCategoryId"
- style="width: 100%"
- @change="changeBomId"
- >
- <el-option
- v-for="item of bomVersionList"
- :key="item.id"
- :label="item.name + '(V' + item.versions + '.0)'"
- :value="item.id"
- ></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="工艺路线:" prop="produceRoutingId">
- <!-- @click.native="openVersion" -->
- <el-select
- v-model="form.produceRoutingId"
- style="width: 100%"
- @change="changeRoute"
- >
- <el-option
- v-for="item of routingList"
- :key="item.id"
- :label="item.name"
- :value="item.id"
- ></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- <ele-pro-table
- ref="table"
- :needPage="false"
- :columns="columns"
- :datasource="datasource"
- @cell-click="cellClick"
- row-key="id"
- >
- <template v-slot:orderNum="{ row }">
- {{ row.orderNum }}
- </template>
- <template v-slot:action="{ row }">
- <el-radio class="radio" v-model="radio" :label="row.id"
- ><i></i
- ></el-radio>
- </template>
- </ele-pro-table>
- <template v-slot:footer>
- <el-button type="primary" @click="save"> 确定 </el-button>
- <el-button @click="updateVisible(false)"> 返回 </el-button>
- </template>
- </ele-modal>
- </template>
- <script>
- import { bomListByPlan, bomRoutingList, taskinstanceList } from '@/api/aps';
- export default {
- components: {},
- props: {
- // 弹窗是否打开
- visible: Boolean
- },
- data() {
- const defaultForm = {
- produceType: '',
- bomCategoryId: '',
- produceRoutingId: ''
- };
- return {
- defaultForm,
- radio: null,
- current: {},
- producedList: [
- { code: 2, name: '加工(MBOM)' },
- { code: 3, name: '装配(ABOM)' }
- ],
- index: '',
- bomVersionList: [],
- routingList: [],
- // 表单数据
- form: { ...defaultForm },
- // 表单验证规则
- rules: {},
- versionList: [],
- // 提交状态
- loading: false,
- // 是否是修改
- isUpdate: false,
- columns: [
- {
- action: 'action',
- slot: 'action',
- align: 'center',
- label: '选择',
- width: 80
- },
- {
- prop: 'orderNum',
- label: '排序',
- align: 'center',
- slot: 'orderNum',
- width: 80
- },
- {
- prop: 'code',
- label: '工序编码',
- // sortable: 'custom',
- 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
- }
- ]
- };
- },
- computed: {
- // 是否开启响应式布局
- styleResponsive() {
- return this.$store.state.theme.styleResponsive;
- }
- },
- methods: {
- open(row, index) {
- this.data = row;
- this.index = index;
- },
- changeProduceType() {
- this.form.bomCategoryId = '';
- this.form['bomCategoryName'] = '';
- this.form['bomCategoryVersions'] = '';
- this.bomVersionList = [];
- this.routingList = [];
- this.form.produceRoutingId = '';
- this.form.produceRoutingName = '';
- this.form.produceVersionName = '';
- this.bomListVersion();
- },
- bomListVersion() {
- let param = {
- bomType: this.form.produceType,
- categoryId: this.data.productId
- };
- bomListByPlan(param).then((res) => {
- this.bomVersionList = res || [];
- });
- },
- changeBomId() {
- this.routingList = [];
- this.form.produceRoutingId = '';
- this.form.produceRoutingName = '';
- this.form.produceVersionName = '';
- this.bomVersionList.forEach((f) => {
- if (f.id == this.form.bomCategoryId) {
- this.$set(this.form, 'bomCategoryName', f.name);
- this.$set(this.form, 'bomCategoryVersions', f.versions);
- }
- });
- this.getPlanRouting();
- },
- getPlanRouting() {
- bomRoutingList(this.form.bomCategoryId).then((res) => {
- this.routingList = res || [];
- });
- },
- changeRoute(val) {
- if (!val) return;
- this.routingList.forEach((f) => {
- if (f.id == this.form.produceRoutingId) {
- this.$set(this.form, 'produceRoutingName', f.name);
- this.$set(this.form, 'produceVersionName', f.version);
- }
- });
- this.$refs.table.reload();
- },
- /* 表格数据源 */
- async datasource() {
- if (this.form.produceRoutingId) {
- const res = await taskinstanceList({
- routingId: this.form.produceRoutingId,
- isDetail: true,
- pageNum: 1,
- size: -1
- });
- let arr = res.list.map((it) => {
- it.detail.orderNum = it.orderNum;
- return it.detail;
- });
- return {
- list: arr
- };
- } else {
- return {
- list: []
- };
- }
- //this.$refs.table.reload()
- },
- // 单击获取id
- cellClick(row) {
- this.current = row;
- this.radio = row.id;
- },
- /* 保存编辑 */
- save() {
- if (!this.radio) return this.$message.warning('请选择工序');
- this.$emit('saveTaskInstance', {
- ...this.current,
- index: this.index,
- produceRoutingId: this.form.produceRoutingId
- });
- this.updateVisible(false);
- },
- /* 更新visible */
- updateVisible(value) {
- this.$emit('update:visible', value);
- }
- },
- watch: {}
- };
- </script>
|